package com.actimize.dao.hibernate;

import com.actimize.dao.TranDao;
import com.actimize.model.Transaction;

import org.springframework.stereotype.Repository;
import java.util.List;
import org.hibernate.Query;

	@Repository("tranDao")
	public class TranDaoHibernate extends GenericDaoHibernate<Transaction, Long> implements TranDao {

	    public TranDaoHibernate() {
	        super(Transaction.class);
	    }

	    public Transaction saveTran(Transaction tran) {
	        if (log.isDebugEnabled()) {
	            log.debug("payee's id: " + tran.getTranId());
	        }
	        getSession().save(tran);
	        // necessary to throw a DataIntegrityViolation and catch it in UserManager
	        getSession().flush();
	        return tran;
	    }

		@Override
		@SuppressWarnings("unchecked")
	    public List<Transaction> getTrans() {
			Query qry = getSession().createQuery("from Transaction )");
			return qry.list();
		}
	}